<%@ page language="java" contentType="text/html; charset=utf-8"
   pageEncoding="utf-8" import="java.util.*,my_web.bean.*,my_web.page.*"%>
<%@taglib prefix="c" uri="http://java.sun.com/jsp/jstl/core"%>
<!DOCTYPE html>
<html>
<head>
<meta charset="UTF-8">
<meta http-equiv="X-UA-Compatible" content="IE=edge">
<meta name="viewport" content="width=device-width, initial-scale=1">
<title>Insert title here</title>
<link href="css/bootstrap.min.css" rel="stylesheet">
</head>	
<body>
<ol class="breadcrumb" style="margin-bottom:5px;">
			<li><a href="#">基础信息</a></li>
			<li class="active">员工信息</li>
</ol>
<div class="container-fluid" style="padding-left:2px;padding-right:2px;">
	<form action="EmpDoMultiDel.do" method="post" name="fenye">
		<div class="panel panel-default" style="padding:5px;">
					<a class="btn btn-default" href="EmpToAdd.do"><span class="glyphicon glyphicon-plus" ></span> 新增</a>
			  		<button type="submit" class="btn btn-default" id="bt1"><span class="glyphicon glyphicon-trash" ></span> 删除</button>
			  		员工编号：<input type="text" name="e_id" value="${param.e_id}" size=5/>
			 		部门名称：<input type="text" name="d_name" value="${param.d_named}" size=5/>
			 		员工姓名：<input type="text" name="e_name" value="${param.e_name}" size=5/>
			 		员工状态：<input type="text" name="e_state" value="${param.e_state}"size=5/>
			  		职位名称：<input type="text" name="p_name" value="${param.p_name}" size=5/>
					<input type="submit" value="查询" formaction="EmpToList.do" size=5/> 		
		</div>
	<table class="table table-bordered" >
		<thead>
			<tr>
				<th>选择</th>
				<th>员工编号</th>
				<th>部门名称</th>
				<th>员工姓名</th>
				<th>员工状态</th>
				<th>职位名称</th>
				<th>操作</th>
			</tr>
		</thead>
		<tbody>
		<c:forEach items="${pg.reclist }" var="emp">
			<tr>
				<td>
					<input type="checkbox" name="e_ids" value="${emp.e_id}"/>
				</td>
				<td>${emp.e_id}</td>
				<td>${emp.d_name}</td>
				<td>${emp.e_name}</td>
				<td>${emp.e_state}</td>
				<td>${emp.p_name}</td>
				<td>
					<a href="EmpDoDel.do?e_id=${emp.e_id}" class="del">删除</a>
			  		<a href="EmpToUpd.do?e_id=${emp.e_id}">修改</a>
				</td>
			</tr>
		</c:forEach>
		</tbody>
	</table>
	</form>
	<nav>
		<ul class="pager">
			<li>
				<a href="" onclick="document.fenye.action='EmpToList.do?page=${pg.first}';document.fenye.submit();return false;">首页</a>
			</li>
			<li>
				<a href="" onclick="document.fenye.action='EmpToList.do?page=${pg.prior}';document.fenye.submit();return false;">上一页</a>
			</li>
			<li>
				<a href="" onclick="document.fenye.action='EmpToList.do?page=${pg.next}';document.fenye.submit();return false;">下一页</a>
			</li>
			<li>
				<a href="" onclick="document.fenye.action='EmpToList.do?page=${pg.last}';document.fenye.submit();return false;">尾页</a>
			</li>
			<li>
				第${pg.curr}页 共${pg.pgTotal}页 共${pg.total}条记录
			</li>
			<li><form action="EmpToList.do" style="display: inline-block;">跳转至
				<input type="text"  name="page" style="width:25px;" value="">页
	 				<button type="submit">GO</button> </form>
	    	</li>
	    </ul>
	</nav>
</div>
<script src="js/jquery-3.3.1.min.js"></script>
<script src="js/bootstrap.min.js"></script>
<script type="text/javascript">
	var del_links=document.querySelectorAll(".del");
	for(var i=0;i<del_links.length;i++){
		del_links[i].onclick=function(){
			if(confirm("您确实要删除该条数据吗？")){
				var xhr=new XMLHttpRequest();
				var url=this.href;
				xhr.open('get', url, true);
				xhr.onreadystatechange=function(){
					if(this.readyState==4){
						var jsonStr=this.responseText;
						//eval('var result='+jsonStr);
						var result=eval("("+jsonStr+")");
						//var result={"success":true,"msg":"删除成功！"};
						if(this.status==200){
							if(result.success){
								alert(result.msg);
								window.location.href='EmpToList.do';
							}else{
								alert(result.msg);
							}
						}else{
							alert("请求地址不正确或者服务器出错！");
						}
					}
				};
				xhr.send();
			}
			return false;
		};
	}
</script>
<script type="text/javascript">
	document.getElementById("bt1").onclick=function(){
		return confirm("你真的要删除该员工的信息吗？想好了哦！");
	}
</script>
</body>
</html>